﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreRay.Collections
{
    /// <summary>
    /// Represents a node used by the BinaryTree collection.
    /// </summary>
    /// <typeparam name="T">Type of the data stored in the node.</typeparam>
    [Serializable]
    public class BinaryTreeNode<T>
    {
        /// <summary>
        /// Initializes a new instance of the BinaryTreeNode class.
        /// </summary>
        /// <param name="data">Data to store in the node.</param>
        public BinaryTreeNode(T data) : this(data, null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the BinaryTreeNode class.
        /// </summary>
        /// <param name="data">Data to store in the node.</param>
        /// <param name="leftChild">Left child node.</param>
        /// <param name="rightChild">Right child node.</param>
        public BinaryTreeNode(T data, BinaryTreeNode<T> leftChild, BinaryTreeNode<T> rightChild)
        {
            // Init properties
            this.Data = data;
            this.LeftChild = leftChild;
            this.RightChild = rightChild;
        }

        /// <summary>
        /// Gets or sets the data stored in the node.
        /// </summary>
        /// <value>Data stored in the node.</value>
        public T Data
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the left child node.
        /// </summary>
        /// <value>Left child node.</value>
        public BinaryTreeNode<T> LeftChild
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the right child node.
        /// </summary>
        /// <value>Right child node.</value>
        public BinaryTreeNode<T> RightChild
        {
            get;
            set;
        }
    }
}
